﻿<style type="text/css">
	fieldset.fs-targets { padding:10px; margin:20px 5px; border:1px solid #ccc; }
		fieldset.fs-targets legend { font-size:16px; font-weight:bold; }
	#fs-send { border-left:5px solid #1a8601; }
		#fs-send legend { color:#1a8601; }
	#fs-back { border-left:5px solid #94231f; }
		#fs-back legend { color:#94231f; }
	#fs-memo { border-left:1px solid #888; }
		#fs-memo legend { color:#666; }
	#handle-div { }
		#handle-div label { font-size: 1.2em; font-family: 微软雅黑,Arial; display: block; }
	dl.handle-list dt { padding: 5px; background-color: #e7f7f8; font-size: 1.2em; font-family: 微软雅黑,Arial; clear: both; }
	dl.handle-list dd { padding: 5px; float: left; }
		dl.handle-list dd span { margin-left: 5px; color: #196a97; }
	a.select-empl { display: block; border: 1px solid #f99709; background-color:#f99709; color:#fff; padding: 2px 4px; text-decoration: none; border-radius: 5px; }
	dl.handle-list p { margin-left: 10px; }
	dl.handle-list span.proc-mode { float: right; font-size: 0.85em; font-family: 宋体; }
		dl.handle-list span.proc-mode i { color: #888; padding: 4px; display: block; }
	span.addr-descr { font-size: 0.85em; color: #aaa; margin-left: 10px; overflow: hidden; }
	#memo-div { display: block; clear: both; }
		#memo-div label { font-size: 1em; display: block; color: #888; }
		#memo-div textarea { width: 660px; border: 1px solid #ccc; }
	#memo-atts ul { list-style:none; margin:0; padding:0; }
		#memo-atts ul li { float:left; display:block; padding:2px; margin:2px 5px; white-space:nowrap; }
	#memo-add-atts { clear:both; }
	#memo-add-atts-btn { display:inline-block; padding:2px 10px; background-color:#f99709; border:1px solid #f99709; border-radius:5px; color:#fff; text-decoration:none; }
	ul.back-list { list-style:none; margin:0; padding:0; }
		ul.back-list dl { margin:0; }
	#wkf-switch-dept { padding:10px; color:#9c4e4e; }
		#wkf-switch-dept a { color:#f00; text-decoration:underline; }
</style>


<fieldset class="fs-targets" id="fs-leader">
    <legend>增加领导批示</legend>
    <div id="leader-div">
        <label></label>
        <dl class="handle-list" id="leader-list">
            <dt>
                <span class="proc-mode">
                </span>
                <input type="checkbox" id="NODE_leader" data-node-type="2" class="chk-leader manual-multi" value="NODE_leader">
                <span id="TITLE_leader">领导批示</span>
                <span class="addr-descr"></span>
            </dt>
            <dd><a href="javascript:void(0)" class="select-empl" data-param="" data-node="NODE_leader" data-handle-mode="multi">添加人员</a></dd>
        </dl>
    </div>
</fieldset>




<script type="text/javascript">
   //检查是否有添加提醒的权限
	//$(function(){
	//	$.ajax({
	//			url: '/Apps/Tiger/Workflow/CheckAddHandlePermission',
	//			type: 'POST',
	//			data: { mid: msg_id},
	//			async: false,
	//			dataType: 'json',
	//			success: function(r) {
	//				if (r.Succeed) {
	//					$("#fs-leader").show();
	//				}
	//			}
	//		});
	//})
</script>

<script type="text/javascript">
	$(function () {

		$('dl.handle-list input[type="checkbox"].all').attr('checked', true);
		$('dl.handle-list input[type="checkbox"].all').attr('disabled', true);

		appkizUI.processDataRole();

		$('dl.handle-list input[type="checkbox"].manual-single').change(function () {
			var cur = $(this).attr('id');
			$('dl.handle-list input[type="checkbox"].manual-single').each(function () {
				if ($(this).attr('id') != cur)
					$(this).attr('checked', false);
			});
		});

		$('dl.handle-list input[type="checkbox"].single').change(function () {
			var single_node_key = $(this).data('node');
			var single_node_id = $(this).attr('id');
			$('dl.handle-list input[type="checkbox"].single').each(function () {
				if ($(this).data('node') == single_node_key) {
					if ($(this).attr('id') != single_node_id) {
						$(this).attr('checked', false);
					}
				}
			});
		});

		$('dl.handle-list input[type="checkbox"].chk-empl').click(function () {
			$(this).parent().parent().find('input.chk-node').attr('checked', true);
			$(this).parent().parent().find('input.chk-node').change();
		});

		$('input.chk-sel-all-handler').click(function () {
			$('input[type="checkbox"][data-node="' + $(this).data('node') + '"]').attr('checked', ($(this).is(':checked') ? true : false));
		});

		$('a.select-empl').click(function () {
			var aobj = $(this).parent();
			var node = $(this).attr('data-node');
			var handle_mode = $(this).attr('data-handle-mode');
			var paramStr = $(this).attr('data-param');

			appkiz.people.getPeopleDlg({
				multiple: (handle_mode != 'single'),
				params: paramStr,
				ok: function (r) {
					if (handle_mode == 'single') {
						$('input[type="checkbox"][data-node="' + node + '"]').parent().remove();
					}
					var emplIdList = '';
					for (var i = 0; i < r.length; i++) {
						emplIdList += (emplIdList.length > 0 ? ',' : '') + r[i].id;
					}
					$.post('/Apps/Workflow/Running/GetPeopleDelegateInfo', { mid: msg_id, emplIdList: emplIdList }, function (plist) {
						for (var i = 0; i < plist.length; i++) {
							var empl = plist[i];
							if ($('#EMPL_' + node + '_' + empl.id).length > 0) continue;

							var html = '<dd data-role="people" data-empl-id="' + empl.id + '">';
							html += '<input type="checkbox" checked id="EMPL_' + node + '_' + empl.id + '" class="chk-empl ' + handle_mode + '" value="' + empl.id + (empl.delegateById.length == 0 ? '' : '#' + empl.delegateById) + '" data-node="' + node + '" />';
							html += empl.name;
							if (empl.delegateByName != '') {
								html += '<span>作为 <b>' + empl.delegateByName + '</b> 的代理人</span>';
							}
							html += '</dd>';
							aobj.before($(html));
						}
					}, 'json');
				}
			});
		});

	});



	function getLeaderInfo() {
	    var warnningList = $('input.chk-leader:checked');
	    if (warnningList.length > 0) {
	        var emplIds = '';
	        $('#leader-list input.chk-empl[data-node="NODE_leader"]:checked').each(function () {
	            var empl = $(this).val();
	            if (emplIds.length > 0) emplIds += ',';
	            emplIds += empl;
	        });
	        if (emplIds.length == 0) {
	            return false;
	        }
	        return emplIds
	    }
	    return false;
	}

</script>